<?php
	/**
	 * This is a MetaControl class, providing a QForm or QPanel access to event handlers
	 * and QControls to perform the Create, Edit, and Delete functionality
	 * of the Articlemovies class.  This code-generated class
	 * contains all the basic elements to help a QPanel or QForm display an HTML form that can
	 * manipulate a single Articlemovies object.
	 *
	 * To take advantage of some (or all) of these control objects, you
	 * must create a new QForm or QPanel which instantiates a ArticlemoviesMetaControl
	 * class.
	 *
	 * Any and all changes to this file will be overwritten with any subsequent
	 * code re-generation.
	 * 
	 * @package My Application
	 * @subpackage MetaControls
	 * property-read Articlemovies $Articlemovies the actual Articlemovies data class being edited
	 * property QLabel $IdControl
	 * property-read QLabel $IdLabel
	 * property QListBox $ReferenceIDControl
	 * property-read QLabel $ReferenceIDLabel
	 * property QTextBox $ActorControl
	 * property-read QLabel $ActorLabel
	 * property QTextBox $DirectorControl
	 * property-read QLabel $DirectorLabel
	 * property QFloatTextBox $RunningTimeControl
	 * property-read QLabel $RunningTimeLabel
	 * property-read string $TitleVerb a verb indicating whether or not this is being edited or created
	 * property-read boolean $EditMode a boolean indicating whether or not this is being edited or created
	 */

	class ArticlemoviesMetaControlGen extends QBaseClass {
		// General Variables
		protected $objArticlemovies;
		protected $objParentObject;
		protected $strTitleVerb;
		protected $blnEditMode;

		// Controls that allow the editing of Articlemovies's individual data fields
		protected $lblId;
		protected $lstReferenceIDObject;
		protected $txtActor;
		protected $txtDirector;
		protected $txtRunningTime;

		// Controls that allow the viewing of Articlemovies's individual data fields
		protected $lblReferenceID;
		protected $lblActor;
		protected $lblDirector;
		protected $lblRunningTime;

		// QListBox Controls (if applicable) to edit Unique ReverseReferences and ManyToMany References

		// QLabel Controls (if applicable) to view Unique ReverseReferences and ManyToMany References


		/**
		 * Main constructor.  Constructor OR static create methods are designed to be called in either
		 * a parent QPanel or the main QForm when wanting to create a
		 * ArticlemoviesMetaControl to edit a single Articlemovies object within the
		 * QPanel or QForm.
		 *
		 * This constructor takes in a single Articlemovies object, while any of the static
		 * create methods below can be used to construct based off of individual PK ID(s).
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this ArticlemoviesMetaControl
		 * @param Articlemovies $objArticlemovies new or existing Articlemovies object
		 */
		 public function __construct($objParentObject, Articlemovies $objArticlemovies) {
			// Setup Parent Object (e.g. QForm or QPanel which will be using this ArticlemoviesMetaControl)
			$this->objParentObject = $objParentObject;

			// Setup linked Articlemovies object
			$this->objArticlemovies = $objArticlemovies;

			// Figure out if we're Editing or Creating New
			if ($this->objArticlemovies->__Restored) {
				$this->strTitleVerb = QApplication::Translate('Edit');
				$this->blnEditMode = true;
			} else {
				$this->strTitleVerb = QApplication::Translate('Create');
				$this->blnEditMode = false;
			}
		 }

		/**
		 * Static Helper Method to Create using PK arguments
		 * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
		 * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
		 * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to 
		 * edit, or if we are also allowed to create a new one, etc.
		 * 
		 * @param mixed $objParentObject QForm or QPanel which will be using this ArticlemoviesMetaControl
		 * @param integer $intId primary key value
		 * @param QMetaControlCreateType $intCreateType rules governing Articlemovies object creation - defaults to CreateOrEdit
 		 * @return ArticlemoviesMetaControl
		 */
		public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			// Attempt to Load from PK Arguments
			if (strlen($intId)) {
				$objArticlemovies = Articlemovies::Load($intId);

				// Articlemovies was found -- return it!
				if ($objArticlemovies)
					return new ArticlemoviesMetaControl($objParentObject, $objArticlemovies);

				// If CreateOnRecordNotFound not specified, throw an exception
				else if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound)
					throw new QCallerException('Could not find a Articlemovies object with PK arguments: ' . $intId);

			// If EditOnly is specified, throw an exception
			} else if ($intCreateType == QMetaControlCreateType::EditOnly)
				throw new QCallerException('No PK arguments specified');

			// If we are here, then we need to create a new record
			return new ArticlemoviesMetaControl($objParentObject, new Articlemovies());
		}

		/**
		 * Static Helper Method to Create using PathInfo arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this ArticlemoviesMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing Articlemovies object creation - defaults to CreateOrEdit
		 * @return ArticlemoviesMetaControl
		 */
		public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$intId = QApplication::PathInfo(0);
			return ArticlemoviesMetaControl::Create($objParentObject, $intId, $intCreateType);
		}

		/**
		 * Static Helper Method to Create using QueryString arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this ArticlemoviesMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing Articlemovies object creation - defaults to CreateOrEdit
		 * @return ArticlemoviesMetaControl
		 */
		public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$intId = QApplication::QueryString('intId');
			return ArticlemoviesMetaControl::Create($objParentObject, $intId, $intCreateType);
		}



		///////////////////////////////////////////////
		// PUBLIC CREATE and REFRESH METHODS
		///////////////////////////////////////////////

		/**
		 * Create and setup QLabel lblId
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblId_Create($strControlId = null) {
			$this->lblId = new QLabel($this->objParentObject, $strControlId);
			$this->lblId->Name = QApplication::Translate('Id');
			if ($this->blnEditMode)
				$this->lblId->Text = $this->objArticlemovies->Id;
			else
				$this->lblId->Text = 'N/A';
			return $this->lblId;
		}

		/**
		 * Create and setup QListBox lstReferenceIDObject
		 * @param string $strControlId optional ControlId to use
		 * @return QListBox
		 */
		public function lstReferenceIDObject_Create($strControlId = null) {
			$this->lstReferenceIDObject = new QListBox($this->objParentObject, $strControlId);
			$this->lstReferenceIDObject->Name = QApplication::Translate('Reference I D Object');
			$this->lstReferenceIDObject->Required = true;
			if (!$this->blnEditMode)
				$this->lstReferenceIDObject->AddItem(QApplication::Translate('- Select One -'), null);
			$objReferenceIDObjectArray = Articlecore::LoadAll();
			if ($objReferenceIDObjectArray) foreach ($objReferenceIDObjectArray as $objReferenceIDObject) {
				$objListItem = new QListItem($objReferenceIDObject->__toString(), $objReferenceIDObject->Id);
				if (($this->objArticlemovies->ReferenceIDObject) && ($this->objArticlemovies->ReferenceIDObject->Id == $objReferenceIDObject->Id))
					$objListItem->Selected = true;
				$this->lstReferenceIDObject->AddItem($objListItem);
			}
			return $this->lstReferenceIDObject;
		}

		/**
		 * Create and setup QLabel lblReferenceID
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblReferenceID_Create($strControlId = null) {
			$this->lblReferenceID = new QLabel($this->objParentObject, $strControlId);
			$this->lblReferenceID->Name = QApplication::Translate('Reference I D Object');
			$this->lblReferenceID->Text = ($this->objArticlemovies->ReferenceIDObject) ? $this->objArticlemovies->ReferenceIDObject->__toString() : null;
			$this->lblReferenceID->Required = true;
			return $this->lblReferenceID;
		}

		/**
		 * Create and setup QTextBox txtActor
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtActor_Create($strControlId = null) {
			$this->txtActor = new QTextBox($this->objParentObject, $strControlId);
			$this->txtActor->Name = QApplication::Translate('Actor');
			$this->txtActor->Text = $this->objArticlemovies->Actor;
			$this->txtActor->TextMode = QTextMode::MultiLine;
			return $this->txtActor;
		}

		/**
		 * Create and setup QLabel lblActor
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblActor_Create($strControlId = null) {
			$this->lblActor = new QLabel($this->objParentObject, $strControlId);
			$this->lblActor->Name = QApplication::Translate('Actor');
			$this->lblActor->Text = $this->objArticlemovies->Actor;
			return $this->lblActor;
		}

		/**
		 * Create and setup QTextBox txtDirector
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtDirector_Create($strControlId = null) {
			$this->txtDirector = new QTextBox($this->objParentObject, $strControlId);
			$this->txtDirector->Name = QApplication::Translate('Director');
			$this->txtDirector->Text = $this->objArticlemovies->Director;
			$this->txtDirector->MaxLength = Articlemovies::DirectorMaxLength;
			return $this->txtDirector;
		}

		/**
		 * Create and setup QLabel lblDirector
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblDirector_Create($strControlId = null) {
			$this->lblDirector = new QLabel($this->objParentObject, $strControlId);
			$this->lblDirector->Name = QApplication::Translate('Director');
			$this->lblDirector->Text = $this->objArticlemovies->Director;
			return $this->lblDirector;
		}

		/**
		 * Create and setup QFloatTextBox txtRunningTime
		 * @param string $strControlId optional ControlId to use
		 * @return QFloatTextBox
		 */
		public function txtRunningTime_Create($strControlId = null) {
			$this->txtRunningTime = new QFloatTextBox($this->objParentObject, $strControlId);
			$this->txtRunningTime->Name = QApplication::Translate('Running Time');
			$this->txtRunningTime->Text = $this->objArticlemovies->RunningTime;
			return $this->txtRunningTime;
		}

		/**
		 * Create and setup QLabel lblRunningTime
		 * @param string $strControlId optional ControlId to use
		 * @param string $strFormat optional sprintf format to use
		 * @return QLabel
		 */
		public function lblRunningTime_Create($strControlId = null, $strFormat = null) {
			$this->lblRunningTime = new QLabel($this->objParentObject, $strControlId);
			$this->lblRunningTime->Name = QApplication::Translate('Running Time');
			$this->lblRunningTime->Text = $this->objArticlemovies->RunningTime;
			$this->lblRunningTime->Format = $strFormat;
			return $this->lblRunningTime;
		}



		/**
		 * Refresh this MetaControl with Data from the local Articlemovies object.
		 * @param boolean $blnReload reload Articlemovies from the database
		 * @return void
		 */
		public function Refresh($blnReload = false) {
			if ($blnReload)
				$this->objArticlemovies->Reload();

			if ($this->lblId) if ($this->blnEditMode) $this->lblId->Text = $this->objArticlemovies->Id;

			if ($this->lstReferenceIDObject) {
					$this->lstReferenceIDObject->RemoveAllItems();
				if (!$this->blnEditMode)
					$this->lstReferenceIDObject->AddItem(QApplication::Translate('- Select One -'), null);
				$objReferenceIDObjectArray = Articlecore::LoadAll();
				if ($objReferenceIDObjectArray) foreach ($objReferenceIDObjectArray as $objReferenceIDObject) {
					$objListItem = new QListItem($objReferenceIDObject->__toString(), $objReferenceIDObject->Id);
					if (($this->objArticlemovies->ReferenceIDObject) && ($this->objArticlemovies->ReferenceIDObject->Id == $objReferenceIDObject->Id))
						$objListItem->Selected = true;
					$this->lstReferenceIDObject->AddItem($objListItem);
				}
			}
			if ($this->lblReferenceID) $this->lblReferenceID->Text = ($this->objArticlemovies->ReferenceIDObject) ? $this->objArticlemovies->ReferenceIDObject->__toString() : null;

			if ($this->txtActor) $this->txtActor->Text = $this->objArticlemovies->Actor;
			if ($this->lblActor) $this->lblActor->Text = $this->objArticlemovies->Actor;

			if ($this->txtDirector) $this->txtDirector->Text = $this->objArticlemovies->Director;
			if ($this->lblDirector) $this->lblDirector->Text = $this->objArticlemovies->Director;

			if ($this->txtRunningTime) $this->txtRunningTime->Text = $this->objArticlemovies->RunningTime;
			if ($this->lblRunningTime) $this->lblRunningTime->Text = $this->objArticlemovies->RunningTime;

		}



		///////////////////////////////////////////////
		// PROTECTED UPDATE METHODS for ManyToManyReferences (if any)
		///////////////////////////////////////////////





		///////////////////////////////////////////////
		// PUBLIC ARTICLEMOVIES OBJECT MANIPULATORS
		///////////////////////////////////////////////

		/**
		 * This will save this object's Articlemovies instance,
		 * updating only the fields which have had a control created for it.
		 */
		public function SaveArticlemovies() {
			try {
				// Update any fields for controls that have been created
				if ($this->lstReferenceIDObject) $this->objArticlemovies->ReferenceID = $this->lstReferenceIDObject->SelectedValue;
				if ($this->txtActor) $this->objArticlemovies->Actor = $this->txtActor->Text;
				if ($this->txtDirector) $this->objArticlemovies->Director = $this->txtDirector->Text;
				if ($this->txtRunningTime) $this->objArticlemovies->RunningTime = $this->txtRunningTime->Text;

				// Update any UniqueReverseReferences (if any) for controls that have been created for it

				// Save the Articlemovies object
				$this->objArticlemovies->Save();

				// Finally, update any ManyToManyReferences (if any)
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * This will DELETE this object's Articlemovies instance from the database.
		 * It will also unassociate itself from any ManyToManyReferences.
		 */
		public function DeleteArticlemovies() {
			$this->objArticlemovies->Delete();
		}		



		///////////////////////////////////////////////
		// PUBLIC GETTERS and SETTERS
		///////////////////////////////////////////////

		/**
		 * Override method to perform a property "Get"
		 * This will get the value of $strName
		 *
		 * @param string $strName Name of the property to get
		 * @return mixed
		 */
		public function __get($strName) {
			switch ($strName) {
				// General MetaControlVariables
				case 'Articlemovies': return $this->objArticlemovies;
				case 'TitleVerb': return $this->strTitleVerb;
				case 'EditMode': return $this->blnEditMode;

				// Controls that point to Articlemovies fields -- will be created dynamically if not yet created
				case 'IdControl':
					if (!$this->lblId) return $this->lblId_Create();
					return $this->lblId;
				case 'IdLabel':
					if (!$this->lblId) return $this->lblId_Create();
					return $this->lblId;
				case 'ReferenceIDControl':
					if (!$this->lstReferenceIDObject) return $this->lstReferenceIDObject_Create();
					return $this->lstReferenceIDObject;
				case 'ReferenceIDLabel':
					if (!$this->lblReferenceID) return $this->lblReferenceID_Create();
					return $this->lblReferenceID;
				case 'ActorControl':
					if (!$this->txtActor) return $this->txtActor_Create();
					return $this->txtActor;
				case 'ActorLabel':
					if (!$this->lblActor) return $this->lblActor_Create();
					return $this->lblActor;
				case 'DirectorControl':
					if (!$this->txtDirector) return $this->txtDirector_Create();
					return $this->txtDirector;
				case 'DirectorLabel':
					if (!$this->lblDirector) return $this->lblDirector_Create();
					return $this->lblDirector;
				case 'RunningTimeControl':
					if (!$this->txtRunningTime) return $this->txtRunningTime_Create();
					return $this->txtRunningTime;
				case 'RunningTimeLabel':
					if (!$this->lblRunningTime) return $this->lblRunningTime_Create();
					return $this->lblRunningTime;
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

		/**
		 * Override method to perform a property "Set"
		 * This will set the property $strName to be $mixValue
		 *
		 * @param string $strName Name of the property to set
		 * @param string $mixValue New value of the property
		 * @return mixed
		 */
		public function __set($strName, $mixValue) {
			try {
				switch ($strName) {
					// Controls that point to Articlemovies fields
					case 'IdControl':
						return ($this->lblId = QType::Cast($mixValue, 'QControl'));
					case 'ReferenceIDControl':
						return ($this->lstReferenceIDObject = QType::Cast($mixValue, 'QControl'));
					case 'ActorControl':
						return ($this->txtActor = QType::Cast($mixValue, 'QControl'));
					case 'DirectorControl':
						return ($this->txtDirector = QType::Cast($mixValue, 'QControl'));
					case 'RunningTimeControl':
						return ($this->txtRunningTime = QType::Cast($mixValue, 'QControl'));
					default:
						return parent::__set($strName, $mixValue);
				}
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}
	}
?>